#include <Box2D.h>
#include "common.h"
#include "b2Mat22.h"

#ifdef __cplusplus
extern "C" {
#endif

/**default constructor*/
JNIEXPORT jint JNICALL Java_b2Mat22_jni_1b2Mat22(JNIEnv *env, jobject obj)
{
	b2Mat22 *mat = new b2Mat22();
	return (jint)mat;
}

/** constructor for b2Mat22(b2Vec2 c1, b2Vec2 c2) */
JNIEXPORT jint JNICALL Java_b2Mat22_jni_1b2Mat22_1vec(JNIEnv *env, jobject obj, jint c1, jint c2)
{
	b2Vec2 *v1 = (b2Vec2*)c1;
	b2Vec2 *v2 = (b2Vec2*)c2;

	b2Mat22 *mat = new b2Mat22(*v1, *v2);
	return (jint)mat;
}


JNIEXPORT jint JNICALL Java_b2Mat22_jni_1b2Mat22_1float
  (JNIEnv *env, jobject obj, jfloat a11, jfloat a12, jfloat a21, jfloat a22)
{
	b2Mat22* mat = new b2Mat22(a11, a12, a21, a22);
	return (jint)mat;
}

JNIEXPORT void JNICALL Java_b2Mat22_jni_1Set
  (JNIEnv *env, jobject obj, jint me, jint c1, jint c2)
{
	b2Vec2* v1 = (b2Vec2*)c1;
	b2Vec2* v2 = (b2Vec2*)c2;

	b2Mat22* mat = (b2Mat22*)me;
	mat->Set(*c1, *c2);
}

JNIEXPORT void JNICALL Java_b2Mat22_jni_1SetIdentity
  (JNIEnv *env, jobject obj, jint me)
{
	b2Mat22* mat = (b2Mat22*)me;
	mat->SetIdentity();
}

JNIEXPORT void JNICALL Java_b2Mat22_jni_1SetZero
  (JNIEnv *env, jobject obj, jint me)
{
	b2Mat22* mat = (b2Mat22*)me;
	mat->SetZero();
}

JNIEXPORT jint JNICALL Java_b2Mat22_jni_1GetInverse
  (JNIEnv *env, jobject obj, jint me)
{
	b2Mat22* mat = (b2Mat22*)me;
	return (jint)(&mat->GetInverse());
}


JNIEXPORT jint JNICALL Java_b2Mat22_jni_1Solve
  (JNIEnv *env, jobject obj, jint me, jint b)
{
	b2Mat22* mat = (b2Mat22*)me;
	b2Vec2* v = (b2Vec2*)b;

	return (jint)(&mat->Solve(*b));
}


#ifdef __cplusplus
}
#endif
